﻿using CodeGeneratorBootstrap.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CodeGeneratorBootstrap.Template.Web.Views.Shared
{
    public partial class _Layout : ITemplate
    {
        public MetaData Data { get; set; }
        public List<LookupClassModel> lookups { get; set; }
        public List<PickupListModel> pickuplist { get; set; }

        public string Filename
        {
            get { return "_Layout.cshtml"; }
        }
        public string FolderName
        {
            get { return ""; }
        }

        public bool IsGenerateOneTime { get { return true; } }
        public bool IsGenerateFolder { get { return false; } }
        public bool IsRequiredOnlyOneMember { get { return false; } }
        public GenerateStyle GenerateStyle { get { return GenerateStyle.Normal; } }

		//provide method for check Class has GeoLocation attribute
		public bool HasGeoLocationAttribute(ClassModel model)
		{
			foreach(AttributeModel attribute in model._attributes)
			{
				if (attribute.DataType.Name.Equals("GeoLocation"))
				{
					return true;
				}					
			}
			return false;
		}

        public bool HasEventMapper(ClassModel model)
        {
            var result = Data.EventMappers.FindAll(x => x.ClassModel.Id == model.Id);
            if (result.Count() > 0)
                return true;
            else
                return false;
        }
    }
}
